﻿<phone:PhoneApplicationPage
    x:Class="ReorderListBoxDemo.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:rlb="clr-namespace:ReorderListBox;assembly=ReorderListBox"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape"
    Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Margin="12,17,0,18">
            <TextBlock Text="ReorderListBox Demo"
                Style="{StaticResource PhoneTextNormalStyle}" />
            <TextBlock Text="Demo List"
                Margin="8,-7,12,0"
                Style="{StaticResource PhoneTextTitle1Style}" />
        </StackPanel>

        <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="12,0,12,12">
            <CheckBox x:Name="enableReorderCheckbox"
                Content="Enable manual reorder" IsChecked="True" />
        </StackPanel>

        <rlb:ReorderListBox
            x:Name="reorderListBox"
            Grid.Row="2"
            Margin="12,0,12,12"
            IsReorderEnabled="{Binding IsChecked, ElementName=enableReorderCheckbox}"
            ItemsSource="{Binding}"
            d:DataContext="{d:DesignData Source=DesignData.xaml}">
            <rlb:ReorderListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock
                        Margin="12,4,12,4"
                        FontSize="36"
                        Text="{Binding}" />
                </DataTemplate>
            </rlb:ReorderListBox.ItemTemplate>

            <!--
              The ReorderListBoxItem DragHandle template can be customized
              via the ItemContainerStyle. The default polygons are copied below.
            
              Notes:
                - The width MUST be equal to 52, required by other parts of the RLB template.
                - The background SHOULD be non-empty (Transparent is OK) to enable
                  dragging on any part of the handle area, not just the polygons.
            -->
            <!--
            <rlb:ReorderListBox.ItemContainerStyle>
                <Style
                    TargetType="rlb:ReorderListBoxItem">
                    <Setter
                        Property="DragHandleTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <Canvas
                                    Width="52"
                                    Height="48"
                                    Background="Transparent">
                                    <Polygon
                                        Fill="Gray"
                                        Points="16,20 4,20 22,4 22,44 16,44" />
                                    <Polygon
                                        Fill="Gray"
                                        Points="32,28 44,28 26,44 26,4 32,4" />
                                </Canvas>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </rlb:ReorderListBox.ItemContainerStyle>
            -->
        </rlb:ReorderListBox>

    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="False">
            <shell:ApplicationBarIconButton x:Name="addButton"
                IconUri="Icons/add.png" Text="add item"
                Click="addButton_Click" />
            <shell:ApplicationBarIconButton x:Name="removeButton"
                IconUri="Icons/remove.png" Text="remove item"
                Click="removeButton_Click" />
            <shell:ApplicationBarIconButton x:Name="sortButton"
                IconUri="Icons/sort.png" Text="sort"
                Click="sortButton_Click" />
            <shell:ApplicationBarIconButton x:Name="shuffleButton"
                IconUri="Icons/shuffle.png" Text="shuffle"
                Click="shuffleButton_Click" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>